<?php 
 class Myhelper_Utils_Gform{
	
	CONST __TEXT__="TEXT";
	CONST __SELECT__="SELECT";
	CONST __GRID__="grid";
	CONST __HEAD__="head";
	CONST __ROW__="row";
	
	
	CONST __MULTICHOIX__="multichoix";
	CONST __CHECK__="check";
	CONST __TEXTAREA__="textarea";
	CONST __NIVEAU__="niveau";
	
	
	STATIC $__LIST_COMP__=array(
			self::__TEXT__ => "Paragraphe",
			self::__SELECT__ => "Liste de choix",
			self::__GRID__ => "Table de niveau",
			 
			self::__MULTICHOIX__ => "Multi Choix",
			self::__CHECK__ => "Zone a coché",
			self::__TEXTAREA__ => "Paragraphe",
			self::__NIVEAU__ => "Score de niveau",
				
			);
	
	STATIC  $__TEMPLATE__	=	array(
									self::__TEXT__=>"
			
											<div class='control-group'>
												<label class='control-label'>{@label}</label>
												<div class='controls'>
													<input type='text' value='{@value}' name='{@name}' id='{@id}'/>
												</div>
											</div>
			
			 						",
									self::__SELECT__=>"
												<div class='control-group'>
												<label class='control-label'>{@label}</label>
													<div class='controls'>
														<SELECT name='{@name}' id='{@id}'>
															{@options}
														</SELECT>
													</div>
												</div>
									",
									self::__GRID__=>"<input type='text'></input>",
									self::__MULTICHOIX__=>"",
									self::__TEXTAREA__=>"
											<div class='control-group'>
												<label class='control-label'>{@label}</label>
													<div class='controls'>
														<TEXTAREA name='{@name}' id='{@id}'>
															{@value}
														</TEXTAREA>
													</div>
												</div>
									",
									self::__NIVEAU__=>""
								);
	
    
	public $Values=array(
				"id"=>"",
				"value"=>"",
				"name"=>"",
				
			);
	
	
	  public function Listecomp(){
		$option="<option value='{@value}'>{@text}</option>";
		$tmp=$option;
		$options=str_replace(array("{@value}","{@text}"), array("",""), $tmp);
		foreach (self::$__LIST_COMP__ as $key => $value){
			$tmp=$option;
		 
			$options.=str_replace(array("{@value}","{@text}"), array($key,$value), $tmp);
		
		}
		return $options;
	}
	
	public function arrayListecomp(){
		$options['']="";
		foreach (self::$__LIST_COMP__ as $key => $value){
			$options[$key]=$value;
	
		}
		return $options;
	}
	
	public function afectcomp($comp){
		
	}
	
	public function gencomp($type=self::__TEXT__){
		switch($type){
			case self::__TEXT__ : $this->afectcomp(self::$__TEMPLATE__[self::__TEXT__],$value);
			break;
			
			
		}
		
	}
	
	public function htmlform(){
		
	}
	
	static public function genrespform($reponse=array()){
		 
	
		$listcontroler="";
		foreach ($reponse as $value){
		 
				switch($value['typereponse_idtypereponse']){
					case self::__TEXTAREA__ : $listcontroler.= "";
					break;
					case self::__NIVEAU__ : $listcontroler.= "
						<div class='control-group'>
							<label class='control-label'>Label niveau bas</label>
								<div class='controls'>
									<input type='text'  value='".$value['label_ax1']."' placeholder='Niveau bas' name='niveaubas_".$value['idreponse']."' id='niveaubas_".$value['idreponse']."'/>
						
								</div>
						</div>
						<div class='control-group'>
								<label class='control-label'>Label niveau Haut</label>
								<div class='controls'>
									<input type='text' placeholder='Niveau haut' value='".$value['labelrepense']."' name='niveauhaut_".$value['idreponse']."' id='niveauhaut_".$value['idreponse']."'/>
								</div>
						</div>
									
								<div class='control-group'>
								<label class='control-label'>Taille de Niveau </label>
								<div class='controls'>
								<input type='text' placeholder='Taille de niveau' name='tailleniveau' id='tailleniveau'/>
								<input type='text' placeholder='Score' value='".$value['score']." name='score_".$value['idreponse']."' id='score_".$value['idreponse']."'/>
								<input type='text' placeholder='Description' value='".$value['descriptionhelp']."' name='description_".$value['idreponse']."' id='description_".$value['idreponse']."'/>
							</div>
						</div>
					";
					break;
						
					case self::__HEAD__ :$listcontroler.= "
					<div class='control-group'>
							<label class='control-label'>Column</label>
								<div class='controls'>
									<input type='text' placeholder='Head' value='".$value['labelrepense']."' name='colmn_".$value['idreponse']."' id='colmn_".$value['idreponse']."'/>
									<input type='text' placeholder='Taille de niveau' name='tailleniveau_".$value['idreponse']."' id='tailleniveau_".$value['idreponse']."'/>
									<input type='text' placeholder='Score' value='".$value['score']." name='score_".$value['idreponse']."' id='score_".$value['idreponse']."'/>
									<input type='text' placeholder='Description' value='".$value['descriptionhelp']."' name='descriptionncolmn_".$value['idreponse']."' id='descriptionncolmn_".$value['idreponse']."'/>
									<a href='#' class='btn btn-inverse' onclick=\"AppendPage('/e-adminuniv/public/genform/gform/genresponse','".self::__HEAD__."','headgrid');\"><i class='icon-plus-sign icon-white'></i> </a>
								</div>
						</div>
					";
					break;
					case self::__GRID__ :$listcontroler.= "
			
					<b>Entete de tableau</b>
					<div id='headgrid'>
						
						<div class='control-group'>
							<label class='control-label'>Column</label>
								<div class='controls'>
									<input type='text' placeholder='Head' value='".$value['labelrepense']."' name='colmn_".$value['idreponse']."' id='colmn_".$value['idreponse']."'/>
									<input type='text' placeholder='Taille de niveau' name='tailleniveau_".$value['idreponse']."' id='tailleniveau_".$value['idreponse']."'/>
									<input type='text' placeholder='Score' value='".$value['score']." name='score_".$value['idreponse']."' id='score_".$value['idreponse']."'/>
									<input type='text' placeholder='Description' value='".$value['descriptionhelp']."' name='descriptionncolmn_".$value['idreponse']."' id='descriptionncolmn_".$value['idreponse']."'/>
									<a href='#' class='btn btn-inverse' onclick=\"AppendPage('/e-adminuniv/public/genform/gform/genresponse','".self::__HEAD__."','headgrid');\"><i class='icon-plus-sign icon-white'></i> </a>
								</div>
						</div>
					</div>
					<b>Ligne de tableau</b>
					<div id='column'>
						
					<div class='control-group'>
					<label class='control-label'>Ligne Label</label>
					<div class='controls'>
					<input type='text' placeholder='Ligne' name='lignelabel_".$value['idreponse']."' id='lignelabel_".$value['idreponse']."'/>
					<input type='text' placeholder='Description' value='".$value['descriptionhelp']."' name='descriptionnligne_".$value['idreponse']."' id='descriptionnligne_".$value['idreponse']."'/>
					<a href='#' class='btn btn-inverse' onclick=\"AppendPage('/e-adminuniv/public/genform/gform/genresponse','".self::__ROW__."','column');\"><i class='icon-plus-sign icon-white'></i> </a>
					</div>
					</div>
					</div>
						
					";
					break;
					case self::__ROW__ : $listcontroler.= "
					<div class='control-group'>
					<label class='control-label'>Ligne Label</label>
					<div class='controls'>
					<input type='text' placeholder='Ligne' name='lignelabel_".$value['idreponse']."' id='lignelabel_".$value['idreponse']."'/>
					<input type='text' placeholder='Description' value='".$value['descriptionhelp']."' name='descriptionnligne_".$value['idreponse']."' id='descriptionnligne_".$value['idreponse']."'/>
					<a href='#' class='btn btn-inverse' onclick=\"AppendPage('/e-adminuniv/public/genform/gform/genresponse','".self::__ROW__."','column');\"><i class='icon-plus-sign icon-white'></i> </a>
					</div>
					</div>
					";
					break;
						
						
					case (self::__CHECK__ || self::__MULTICHOIX__ || self::__SELECT__ )  :
					$listcontroler.= "
					<div class='control-group'>
					<label class='control-label'><input type='radio' name='default_".$value['idreponse']."' id='default_".$value['idreponse']."'/></label>
					<div class='controls'>
					<input type='text'  placeholder='Option' value='".$value['labelrepense']."' name='option_".$value['idreponse']."' id='option_".$value['idreponse']."'/>
					<input type='text' placeholder='Score' value='".$value['score']." name='score_".$value['idreponse']."' id='score_".$value['idreponse']."'/>
									
					<input type='text' placeholder='Description' value='".$value['descriptionhelp']."' name='descriptionnligne_".$value['idreponse']."' id='descriptionnligne_".$value['idreponse']."'/>
					
					<a href='#' class='btn btn-inverse' onclick=\"AppendPage('/e-adminuniv/public/genform/gform/genresponse','".self::__CHECK__."','responsetype');\"><i class='icon-plus-sign icon-white'></i> </a>
					</div>
						
					</div>
					";
						
					;
					break;
						
			
			
				}
		}
		return $listcontroler;
	
		}
	
	
	public function forgenform($type=self::__TEXT__,$scoreresponse=false, $description=false,$reponse=array()){
		$scorestr=$descriptiontext="";
		if($scoreresponse){
			$scorestr="<input type='text' placeholder='Score' name='score[]' id='score[]'/>";
		}
		if($description){
			$descriptiontext="<input type='text' placeholder='Description' name='description[]' id='description[]'/>";
		}
		
		
		
		
			
		switch($type){
			case self::__TEXTAREA__ : return "";
			break;
			case self::__NIVEAU__ : return "
					<div class='control-group'>
						<label class='control-label'>Label niveau bas</label>
						<div class='controls'>
							<input type='text' placeholder='Niveau bas' name='niveaubas' id='niveaubas'/>
							 
						</div>
					</div>
					<div class='control-group'>
						<label class='control-label'>Label niveau Haut</label>
						<div class='controls'>
							<input type='text' placeholder='Niveau haut' name='niveauhaut' id='niveauhaut'/>
							 
						</div>
					</div>
					
					<div class='control-group'>
						<label class='control-label'>Taille de Niveau </label>
						<div class='controls'>
							<input type='text' placeholder='Taille de niveau' name='tailleniveau' id='tailleniveau'/>
							$scorestr
							<input type='text' placeholder='Description' name='description' id='description'/>
						</div>
					</div>
			";
			break;
			
			case self::__HEAD__ :return "
					<div class='control-group'>
							<label class='control-label'>Column</label>
							<div class='controls'>
								<input type='text' placeholder='Head' name='head[]' id='head[]'/>
								$scorestr
								<input type='text' placeholder='Taille de niveau' name='tailleniveau[]' id='tailleniveau[]'/>
								<input type='text' placeholder='Description' name='descriptionnhead[]' id='descriptionnhead[]'/>
								<a href='#' class='btn btn-inverse' onclick=\"AppendPage('/e-adminuniv/public/genform/gform/genresponse','".self::__HEAD__."','headgrid');\"><i class='icon-plus-sign icon-white'></i> </a>
							</div>
						</div>
			";
			break;
			case self::__GRID__ :return "
			 
			<b>Entete de tableau</b>
			<div id='headgrid'>
			
					<div class='control-group'>
							<label class='control-label'>Column</label>
							<div class='controls'>
								<input type='text' placeholder='Head' name='colmn[]' id='colmn[]'/>
								<input type='text' placeholder='Taille de niveau' name='tailleniveau[]' id='tailleniveau[]'/>
								$scorestr
								<input type='text' placeholder='Description' name='descriptionncolmn[]' id='descriptionncolmn[]'/>
								<a href='#' class='btn btn-inverse' onclick=\"AppendPage('/e-adminuniv/public/genform/gform/genresponse','".self::__HEAD__."','headgrid');\"><i class='icon-plus-sign icon-white'></i> </a>
							</div>
						</div>
			</div>
			<b>Ligne de tableau</b>
			<div id='column'>
			
				<div class='control-group'>
						<label class='control-label'>Ligne Label</label>
						<div class='controls'>
							<input type='text' placeholder='Ligne' name='lignelabel[]' id='lignelabel[]'/>
							<input type='text' placeholder='Description' name='descriptionnligne[]' id='descriptionnligne[]'/>
							<a href='#' class='btn btn-inverse' onclick=\"AppendPage('/e-adminuniv/public/genform/gform/genresponse','".self::__ROW__."','column');\"><i class='icon-plus-sign icon-white'></i> </a>
						</div>
					</div>
			</div>
			
			";
			break;
			case self::__ROW__ : return "
					<div class='control-group'>
						<label class='control-label'>Ligne Label</label>
						<div class='controls'>
							<input type='text' placeholder='Ligne' name='lignelabel[]' id='lignelabel[]'/>
							$descriptiontext
							<a href='#' class='btn btn-inverse' onclick=\"AppendPage('/e-adminuniv/public/genform/gform/genresponse','".self::__ROW__."','column');\"><i class='icon-plus-sign icon-white'></i> </a>
						</div>
					</div>
			";
			break;
			
			
			case (self::__CHECK__ || self::__MULTICHOIX__ || self::__SELECT__ )  :
				return "
				<div class='control-group'>
					<label class='control-label'><input type='radio' name='default[]' id='default[]'/></label>
					<div class='controls'>
						<input type='text' placeholder='Option' name='option[]' id='option[]'/>
						$scorestr
						$descriptiontext
						<a href='#' class='btn btn-inverse' onclick=\"AppendPage('/e-adminuniv/public/genform/gform/genresponse','".self::__CHECK__."','responsetype');\"><i class='icon-plus-sign icon-white'></i> </a>
					</div>
					
				</div>
				";
			
				;
				break;
			
				
				
		}
		
	}
	
}